package com.cupk.service;

import com.cupk.entity.Movie;
import com.cupk.repository.MovieRepository;

import java.util.List;

/**
 * @author LY
 * @version 1.0
 */
public class MovieService {
    private MovieRepository movieRepository = new MovieRepository();

    //得到所有电影列表
    public List<Movie> findAll() {
        return movieRepository.findAll();
    }

    //根据id找到电影
    public Movie findById(int id) {
        return movieRepository.findById(id);
    }

    //根据一组id返回电影序列
    public List<Movie> findByIdGroup(Integer[] collectible) {
        return movieRepository.findByIdGroup(collectible);
    }

    //根据关键词查找电影
    public List<Movie> findMovies(String movieName) {
        return movieRepository.findMovies(movieName);
    }

    //找到同类型所有电影，并返回列表
    public List<Movie> findByType(String type, boolean limit) {
        return movieRepository.findByType(type, limit);
    }

    //按地区查找电影，并返回列表
    public List<Movie> findByArea(String area) {
        return movieRepository.findByArea(area);
    }

    //更新评分
    public void updateGrade(Integer id, Double grade, Integer number) {
        movieRepository.updateGrade(id, grade, number);
    }

    //添加评论
    public void addComments(String comment, Integer id) {
        movieRepository.addComments(comment, id);
    }

    //添加新电影
    public void addMovie(String name, String year, String direct, String actor, String area, String type, String content, Integer length, String language) {
        movieRepository.addMovie(name, year, direct, actor, area, type, content, length, language);
    }

}
